package com.ruoyi.web.controller.fantasy;

import java.util.List;

import com.huanzhidadi.fantasy.bean.domain.FantasyActiveCondition;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fantasy.service.IFantasyActiveConditionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 激活条件 信息操作处理
 * 
 * @author wanghui
 * @date 2019-07-05
 */
@Controller
@RequestMapping("/fantasy/fantasyActiveCondition")
public class FantasyActiveConditionController extends BaseController
{
    private String prefix = "fantasy/fantasyActiveCondition";
	
	@Autowired
	private IFantasyActiveConditionService fantasyActiveConditionService;
	
	@RequiresPermissions("fantasy:fantasyActiveCondition:view")
	@GetMapping()
	public String fantasyActiveCondition()
	{
	    return prefix + "/fantasyActiveCondition";
	}
	
	/**
	 * 查询激活条件列表
	 */
	@RequiresPermissions("fantasy:fantasyActiveCondition:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasyActiveCondition fantasyActiveCondition)
	{
		startPage();
        List<FantasyActiveCondition> list = fantasyActiveConditionService.selectFantasyActiveConditionList(fantasyActiveCondition);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出激活条件列表
	 */
	@RequiresPermissions("fantasy:fantasyActiveCondition:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasyActiveCondition fantasyActiveCondition)
    {
    	List<FantasyActiveCondition> list = fantasyActiveConditionService.selectFantasyActiveConditionList(fantasyActiveCondition);
        ExcelUtil<FantasyActiveCondition> util = new ExcelUtil<FantasyActiveCondition>(FantasyActiveCondition.class);
        return util.exportExcel(list, "fantasyActiveCondition");
    }
	
	/**
	 * 新增激活条件
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存激活条件
	 */
	@RequiresPermissions("fantasy:fantasyActiveCondition:add")
	@Log(title = "激活条件", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasyActiveCondition fantasyActiveCondition)
	{		
		return toAjax(fantasyActiveConditionService.insertFantasyActiveCondition(fantasyActiveCondition));
	}

	/**
	 * 修改激活条件
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		FantasyActiveCondition fantasyActiveCondition = fantasyActiveConditionService.selectFantasyActiveConditionById(id);
		mmap.put("fantasyActiveCondition", fantasyActiveCondition);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存激活条件
	 */
	@RequiresPermissions("fantasy:fantasyActiveCondition:edit")
	@Log(title = "激活条件", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasyActiveCondition fantasyActiveCondition)
	{		
		return toAjax(fantasyActiveConditionService.updateFantasyActiveCondition(fantasyActiveCondition));
	}
	
	/**
	 * 删除激活条件
	 */
	@RequiresPermissions("fantasy:fantasyActiveCondition:remove")
	@Log(title = "激活条件", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(fantasyActiveConditionService.deleteFantasyActiveConditionByIds(ids));
	}
	
}
